
function ListNode(val, next) {
    this.val = (val===undefined ? 0 : val)
    this.next = (next===undefined ? null : next)
}

// 反转 head 链表，然后返回反转后的新的头节点
function reverseList(head, val) {
    if (head == null || head.next == null) return head

    const ret = reverseList(head.next)

    // 反转两个节点
    head.next.next = head
    head.next = null

    return ret
}



